<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateWorkOrdersApplyTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('work_order_apply_main', function (Blueprint $table) {
            $table->id();
            $table->string('workOrderNo', 32)->default('')->comment('工单号');
            $table->unsignedInteger('shopId')->default(0)->comment('店铺id');
            $table->unsignedInteger('problemPid')->default(0)->comment('父级问题类型');
            $table->unsignedSmallInteger('problemChildId')->default(0)->comment('子级问题类型');
            $table->string('problemDesc', 255)->default('')->comment('问题描述');
            $table->unsignedInteger('status')->default(1)->comment('工单状态 0关闭 1进行中 2完成');
            $table->unsignedTinyInteger('step')->default(1)->comment('阶段'.enumToMigrationComment(\App\Enums\WorkOrder\MissionEnum::STEP_TEXT));
            $table->unsignedTinyInteger('priority')->default(0)->comment('优先级 0未填（最低） 1低 2中 3高');
            $table->unsignedInteger('completeTime')->default(0)->comment('完成/关闭时间戳');
            $table->string("extra", 1200)->default("")->comment("额外信息");

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->unsignedTinyInteger('isDeleted')->default(0);
            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '工单 - 工单申请主表';

            $table->unique('workOrderNo', 'idx_workOrderNo');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('work_order_apply_main');
    }
}
